import asyncio
from pyppeteer import launch
import time

async def get_page_info():
    url = 'https://pai.crecgec.com/#/auction/auction-detail?enquiryId=1965206398526214145'
    executable_path = "C:/Program Files/Google/Chrome/Application/chrome.exe"  # 修改为您的实际路径

    browser = await launch(
        headless=True,
        executablePath=executable_path,
        args=['--disable-infobars', '--no-sandbox']
    )
    page = await browser.newPage()

    # 修改浏览器指纹
    await page.evaluateOnNewDocument('''() => {
        Object.defineProperty(navigator, 'webdriver', { get: () => false });
        window.chrome = { runtime: {} };
    }''')
    await page.setUserAgent(
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36')

    try:
        await page.goto(url, waitUntil='networkidle2', timeout=60000)


        title = await page.title()
        html_content = await page.content()


        print(f"页面标题: {title}")

        print(f"HTML内容前500字符: {html_content[:500]}...")

    except Exception as e:
        print(f"执行异常: {e}")
    finally:
        await browser.close()


if __name__ == "__main__":
    start_time = time.perf_counter()
    asyncio.run(get_page_info())
    print("调用完毕")


    total_time = time.perf_counter() - start_time
    print(f"整个脚本总耗时: {total_time:.2f} 秒")